<?php 

// +---------------------------------------------+
// |     Copyright  2010 - 2018 InterPhoto       |
// |     http://www.weentech.com                 |
// |     This file may not be redistributed.     |
// +---------------------------------------------+


include('includes/Admin.Core.php');

CheckAccess('manageimage');


$getfiles = explode('/', base64_decode(ForceIncomingString('file')));
$javascriptsize = ForceIncomingInt('size');

switch ($getfiles[1])
{
	case '0':
		$imagesize = "32x32";
		break;
	case '1':
		$imagesize = "80x80";
		break;
	case '2':
		$imagesize = "160x160";
		break;
}

if($javascriptsize == 8){
	$imagesize = "160x160";
}

$image_path = BASEPATH.'MyWebsiteImages/'.ForceDir($getfiles[0]).'_'.WEBSITE_KEY.'/'.$imagesize.'/'.ForceDir($getfiles[2]);

header("Expires: " . gmdate("D, d M Y H:i:s", time() + (30 * 86400)) . " GMT");
header('Content-Type: image/jpeg');

if (file_exists($image_path)) {

	echo fread(fopen($image_path, 'r'), filesize($image_path));
	@fclose($image_path);
	
} else {
	$image_path = BASEPATH . 'includes/images/'.$imagesize.'_missing.gif';
	echo fread(fopen($image_path, 'r'), filesize($image_path));
	@fclose($image_path);
}

?>